﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace FCP.Data.Migrations
{
    public partial class add_search_field_drop_filter : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<bool>(
                name: "dropdown_is_enable_status",
                table: "t_table_field",
                type: "boolean",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<string>(
                name: "dropdown_api",
                table: "t_search_field",
                type: "character varying(600)",
                maxLength: 600,
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "dropdown_dest_field",
                table: "t_search_field",
                type: "character varying(600)",
                maxLength: 600,
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "dropdown_entity_name",
                table: "t_search_field",
                type: "character varying(600)",
                maxLength: 600,
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "dropdown_filter_field",
                table: "t_search_field",
                type: "character varying(600)",
                maxLength: 600,
                nullable: true);

            migrationBuilder.AddColumn<int>(
                name: "dropdown_filter_org_type",
                table: "t_search_field",
                type: "integer",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<string>(
                name: "dropdown_id_field",
                table: "t_search_field",
                type: "character varying(600)",
                maxLength: 600,
                nullable: true);

            migrationBuilder.AddColumn<bool>(
                name: "dropdown_is_enable_status",
                table: "t_search_field",
                type: "boolean",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<bool>(
                name: "dropdown_keep_value_by_no_src",
                table: "t_search_field",
                type: "boolean",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<string>(
                name: "dropdown_label_field",
                table: "t_search_field",
                type: "character varying(600)",
                maxLength: 600,
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "dropdown_service_code",
                table: "t_search_field",
                type: "character varying(600)",
                maxLength: 600,
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "dropdown_show_field",
                table: "t_search_field",
                type: "character varying(600)",
                maxLength: 600,
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "dropdown_sort_field",
                table: "t_search_field",
                type: "character varying(600)",
                maxLength: 600,
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "dropdown_sort_order",
                table: "t_search_field",
                type: "character varying(600)",
                maxLength: 600,
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "dropdown_src_field",
                table: "t_search_field",
                type: "character varying(600)",
                maxLength: 600,
                nullable: true);

            migrationBuilder.AddColumn<bool>(
                name: "dropdown_is_enable_status",
                table: "t_edit_field",
                type: "boolean",
                nullable: false,
                defaultValue: false);

            migrationBuilder.CreateTable(
                name: "t_search_field_filter_field",
                columns: table => new
                {
                    id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
                    search_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    search_field_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    search_field_filter_group_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    org_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    create_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    modify_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    is_deleted = table.Column<bool>(type: "boolean", nullable: false),
                    row_version = table.Column<int>(type: "integer", nullable: false),
                    fcp_form_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    field_name = table.Column<string>(type: "character varying(600)", maxLength: 600, nullable: true),
                    operate_type = table.Column<int>(type: "integer", nullable: false),
                    value = table.Column<string>(type: "character varying(600)", maxLength: 600, nullable: true),
                    is_custom_field = table.Column<bool>(type: "boolean", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_t_search_field_filter_field", x => x.id);
                });

            migrationBuilder.CreateTable(
                name: "t_search_field_filter_group",
                columns: table => new
                {
                    id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
                    search_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    search_field_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    org_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    create_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    modify_time = table.Column<DateTime>(type: "timestamp without time zone", nullable: true),
                    is_deleted = table.Column<bool>(type: "boolean", nullable: false),
                    row_version = table.Column<int>(type: "integer", nullable: false),
                    parent_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    is_leaf = table.Column<bool>(type: "boolean", nullable: false),
                    fcp_form_id = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
                    code = table.Column<string>(type: "character varying(600)", maxLength: 600, nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_t_search_field_filter_group", x => x.id);
                });
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "t_search_field_filter_field");

            migrationBuilder.DropTable(
                name: "t_search_field_filter_group");

            migrationBuilder.DropColumn(
                name: "dropdown_is_enable_status",
                table: "t_table_field");

            migrationBuilder.DropColumn(
                name: "dropdown_api",
                table: "t_search_field");

            migrationBuilder.DropColumn(
                name: "dropdown_dest_field",
                table: "t_search_field");

            migrationBuilder.DropColumn(
                name: "dropdown_entity_name",
                table: "t_search_field");

            migrationBuilder.DropColumn(
                name: "dropdown_filter_field",
                table: "t_search_field");

            migrationBuilder.DropColumn(
                name: "dropdown_filter_org_type",
                table: "t_search_field");

            migrationBuilder.DropColumn(
                name: "dropdown_id_field",
                table: "t_search_field");

            migrationBuilder.DropColumn(
                name: "dropdown_is_enable_status",
                table: "t_search_field");

            migrationBuilder.DropColumn(
                name: "dropdown_keep_value_by_no_src",
                table: "t_search_field");

            migrationBuilder.DropColumn(
                name: "dropdown_label_field",
                table: "t_search_field");

            migrationBuilder.DropColumn(
                name: "dropdown_service_code",
                table: "t_search_field");

            migrationBuilder.DropColumn(
                name: "dropdown_show_field",
                table: "t_search_field");

            migrationBuilder.DropColumn(
                name: "dropdown_sort_field",
                table: "t_search_field");

            migrationBuilder.DropColumn(
                name: "dropdown_sort_order",
                table: "t_search_field");

            migrationBuilder.DropColumn(
                name: "dropdown_src_field",
                table: "t_search_field");

            migrationBuilder.DropColumn(
                name: "dropdown_is_enable_status",
                table: "t_edit_field");
        }
    }
}
